package io.renren.modules.sys.service.impl;

import com.baomidou.mybatisplus.mapper.Wrapper;
import io.renren.common.annotation.DataFilter;
import io.renren.common.utils.Constant;
import io.renren.modules.sys.entity.SysDeptRegEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.OrdertrackingDao;
import io.renren.modules.sys.entity.OrdertrackingEntity;
import io.renren.modules.sys.service.OrdertrackingService;


@Service("ordertrackingService")
public class OrdertrackingServiceImpl extends ServiceImpl<OrdertrackingDao, OrdertrackingEntity> implements OrdertrackingService {
    @Autowired
    private OrdertrackingServiceImpl OrdertrackingService;

    @Override
    @DataFilter(subDept = true, user = false)
    public PageUtils queryPage(Map<String, Object> params) {
        Page<OrdertrackingEntity> page = this.selectPage(
                new Query<OrdertrackingEntity>(params).getPage(),
                new EntityWrapper<OrdertrackingEntity>()
                    .addFilterIfNeed(params.get(Constant.SQL_FILTER) != null, (String)params.get(Constant.SQL_FILTER))
        );
        int countOrdertracking = 0 ;
        Wrapper<OrdertrackingEntity> wrapperUtil = new EntityWrapper<>();
        countOrdertracking = OrdertrackingService.selectCount(wrapperUtil
                .addFilterIfNeed(params.get(Constant.SQL_FILTER) != null, (String)params.get(Constant.SQL_FILTER)));
        page.setTotal(countOrdertracking);
        return new PageUtils(page);
    }

}
